#!/bin/bash

if [ $# -lt 1 ];
then
echo "USAGE: $0 [start|restart xxxxxx.sh]|stop"
exit 1
fi

base_dir=$(dirname $0)
COMMAND=$1

case $COMMAND in
start)
echo 'begin to start..';
shift
sh $base_dir/$1
;;
stop)
echo 'begin to stop..';
PIDS=$(ps ax | grep java | grep -i to-hdfs | grep -v grep | awk '{print $1}')
if [ -z "$PIDS" ]; then
echo "No server to stop"
##exit 1
else
kill -9 $PIDS
fi;
;;
restart)
echo 'begin to restart..';
sh $0 stop
shift
sh $0 start $1
;;
*)
echo 'command is unvalid!';
;;
esac

echo "$COMMAND end!"